//
//  WPTransHistoryTableViewCell.m
//  ZhongChouPingTai
//
//  Created by WeiPan on 16/4/8.
//  Copyright © 2016年 WPJoe. All rights reserved.
//

#import "WPTransHistoryTableViewCell.h"

@interface WPTransHistoryTableViewCell ()
@property (nonatomic, strong) UIImageView * posterImageView;/**< 海报 */
@property (nonatomic, strong) UILabel * titleLabel;/**< 标题文本 */
@property (nonatomic, strong) UILabel * timeLabel;/**< 时间文本 */
@property (nonatomic, strong) UITextField * positionTextField;/**< 票号位置文本 */
@property (nonatomic, strong) UITextField * buyinPriceTextField;/**< 买入价格 */
@property (nonatomic, strong) UITextField * sellTextField;/**< 转出价格 */
@property (nonatomic, strong) UIView * line;/**< 线 */
- (void)initializeAppearance;/**< 一般界面初始化 */


@end

@implementation WPTransHistoryTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initializeAppearance];
    }
    return self;
}
#pragma mark - init
- (void)initializeAppearance {
    [self addSubview:self.posterImageView];
    [self addSubview:self.titleLabel];
    [self addSubview:self.timeLabel];
    [self addSubview:self.positionTextField];
    [self addSubview:self.buyinPriceTextField];
    [self addSubview:self.sellTextField];
    [self addSubview:self.line];
}
#pragma mark - setter
- (void)setModel:(WPTransHistoryModel *)model {
    _model = model;
    _posterImageView.image = IMAGE_NAME(model.poster);
    _titleLabel.text = model.title;
    _timeLabel.text = model.time;
    _positionTextField.text = model.position;
    _buyinPriceTextField.text = model.buyInPrice;
    _sellTextField.text = model.sellPrice;
}

#pragma mark - getter
- (UIImageView *)posterImageView {
    if (!_posterImageView) {
        _posterImageView = ({
            UIImageView * view = [[UIImageView alloc]initWithFrame:CGRectMake(5*DHFlexibleHorizontalMutiplier(), 10*DHFlexibleHorizontalMutiplier(), 75*DHFlexibleHorizontalMutiplier(), 55*DHFlexibleHorizontalMutiplier())];
            view;
        });
    }
    return _posterImageView;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = ({
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(85*DHFlexibleHorizontalMutiplier(), CGRectGetMinY(self.posterImageView.frame), 130*DHFlexibleHorizontalMutiplier(), 20*DHFlexibleHorizontalMutiplier())];
            lab.font = [UIFont systemFontOfSize:12*DHFlexibleHorizontalMutiplier()];
            lab.textColor = COLOR_RGB(61, 61, 61, 1);
            lab;
        });
    }
    return _titleLabel;
}
- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = ({
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.titleLabel.frame), CGRectGetMinY(self.titleLabel.frame), 95*DHFlexibleHorizontalMutiplier(), 20*DHFlexibleHorizontalMutiplier())];
            lab.font = [UIFont systemFontOfSize:10*DHFlexibleHorizontalMutiplier()];
            lab.textAlignment = NSTextAlignmentRight;
            lab.textColor = COLOR_RGB(181, 181, 181, 1);
            lab;
        });
    }
    return _timeLabel;
}
- (UITextField *)positionTextField {
    if (!_positionTextField) {
        _positionTextField = ({
            UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.titleLabel.frame), CGRectGetMaxY(self.timeLabel.frame), 200, 20*DHFlexibleHorizontalMutiplier())];
            text.leftViewMode = UITextFieldViewModeAlways;
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 35*DHFlexibleHorizontalMutiplier(), 20*DHFlexibleHorizontalMutiplier())];
            lab.font = [UIFont systemFontOfSize:11*DHFlexibleHorizontalMutiplier()];
            lab.textColor = COLOR_RGB(102, 102, 102, 1);
            lab.text = @"票号：";
            text.leftView = lab;
            text.font = [UIFont systemFontOfSize:12*DHFlexibleHorizontalMutiplier()];
            text.textColor = COLOR_RGB(102, 102, 102, 1);
            text.userInteractionEnabled= NO;
            text;
        });
    }
    return _positionTextField;
}
- (UITextField *)buyinPriceTextField {
    if (!_buyinPriceTextField) {
        _buyinPriceTextField = ({
            UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.titleLabel.frame), CGRectGetMaxY(self.positionTextField.frame), 105*DHFlexibleHorizontalMutiplier(), 20*DHFlexibleHorizontalMutiplier())];
            text.leftViewMode = UITextFieldViewModeAlways;
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 55*DHFlexibleHorizontalMutiplier(), 20*DHFlexibleHorizontalMutiplier())];
            lab.font = [UIFont systemFontOfSize:11*DHFlexibleHorizontalMutiplier()];
            lab.textColor = COLOR_RGB(102, 102, 102, 1);
            lab.text = @"购买价：¥";
            text.leftView = lab;
            text.font = [UIFont systemFontOfSize:14*DHFlexibleHorizontalMutiplier()];
            text.textColor = COLOR_RGB(234, 27, 47, 1);
            text.userInteractionEnabled= NO;
            text;

        });
    }
    return _buyinPriceTextField;
}
- (UITextField *)sellTextField {
    if (!_sellTextField) {
        _sellTextField = ({
            UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.buyinPriceTextField.frame), CGRectGetMaxY(self.positionTextField.frame), 105*DHFlexibleHorizontalMutiplier(), 20*DHFlexibleHorizontalMutiplier())];
            text.leftViewMode = UITextFieldViewModeAlways;
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 55*DHFlexibleHorizontalMutiplier(), 20*DHFlexibleHorizontalMutiplier())];
            lab.font = [UIFont systemFontOfSize:11*DHFlexibleHorizontalMutiplier()];
            lab.textColor = COLOR_RGB(102, 102, 102, 1);
            lab.text = @"转售价：¥";
            text.leftView = lab;
            text.font = [UIFont systemFontOfSize:14*DHFlexibleHorizontalMutiplier()];
            text.textColor = COLOR_RGB(234, 27, 47, 1);
            text.userInteractionEnabled= NO;
            text;
        });
    }
    return _sellTextField;
}
- (UIView *)line {
    if (!_line) {
        _line = ({
            UIView * line = [[UIView alloc]initWithFrame:CGRectMake(10*DHFlexibleHorizontalMutiplier(), 74*DHFlexibleHorizontalMutiplier(), 300*DHFlexibleHorizontalMutiplier(), 1)];
            line.backgroundColor = BGCOLOR;
            line;
        });
    }
    return _line;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
